package com.wf.provider;

import com.wf.entity.PageInfo;
import com.wf.entity.Menu;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
 * Created by yuzhongbo on 2017/5/3.
 */
@Component
@FeignClient("wf-power")
public interface MenuProvider {

    //Operation(value="获取菜单列表", notes="根据Menu获取菜单列表")
    //ImplicitParam(name = "menu", value = "Menu", required = false, dataType = "Menu")
    @LoadBalanced
    @RequestMapping(value = "/menu")
    public PageInfo<Menu> getAllByPage(@ModelAttribute(value = "menu") Menu menu);

    //Operation(value="获取菜单", notes="根据菜单id获取菜单")
    //ImplicitParam(name = "id", value = "菜单id", required = true, dataType = "String")
    @LoadBalanced
    @RequestMapping(value = "/menu/get/{id}")
    public Menu get(@PathVariable(value = "id") String id);

    //Operation(value="删除菜单", notes="根据菜单id删除菜单")
    //ImplicitParam(name = "id", value = "菜单id", required = true, dataType = "String")
    @LoadBalanced
    @RequestMapping(value = "/menu/delete/{id}")
    public ModelMap delete(@PathVariable(value = "id") String id);

    //Operation(value="保存（添加/修改）菜单", notes="根据Menu创建菜单")
    //ImplicitParam(name = "menu", value = "菜单实体Menu", required = true, dataType = "Menu")
    @LoadBalanced
    @RequestMapping(value = "/menu/save", method = RequestMethod.POST)
    public ModelMap save(@ModelAttribute(value = "menu") Menu menu);

    //Operation(value="获取用户菜单", notes="根据用户id获取用户菜单")
    //ImplicitParam(name = "id", value = "用户id", required = true, dataType = "String")
    @LoadBalanced
    @RequestMapping(value = "/menu/getMenusByUserId/{userId}")
    public List<Menu> getMenusByUserId(@PathVariable(value = "userId") String userId);

    //Operation(value="获取角色菜单", notes="根据角色id获取用户菜单")
    //ImplicitParam(name = "id", value = "角色id", required = true, dataType = "String")
    @LoadBalanced
    @RequestMapping(value = "/menu/getMenusByRoleId/{roleId}")
    public List<Menu> getMenusByRoleId(@PathVariable(value = "roleId") String roleId);

    //Operation(value="获取用户菜单JSON", notes="根据用户id获取用户菜单JSON")
    //ImplicitParam(name = "id", value = "用户id", required = true, dataType = "String")
    @LoadBalanced
    @RequestMapping(value = "/menu/getMenusJsonByUserId/{userId}")
    public String getMenusJsonByUserId(@PathVariable(value = "userId") String userId);

    //Operation(value="获取用户菜单JSON", notes="根据用户id获取用户菜单JSON")
    @LoadBalanced
    @RequestMapping(value = "/menu/getMenusJson")
    public String getMenusJson();
}
